/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frm.billingAndPaymentProcessing.managedbean;

import crm.clientManagement.entity.CompanyEntity;
import crm.salesOrderProcessing.entity.LineItemEntity;
import frm.billingAndPaymentProcessing.entity.InvoiceEntity;
import frm.billingAndPaymentProcessing.entity.ReceiptEntity;
import java.io.IOException;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;

/**
 *
 * @author xhx
 */
@ManagedBean
@ViewScoped
public class ReceiptSheetManagedBean {
private ReceiptEntity receipt;
private InvoiceEntity invoice;
private CompanyEntity company;
private List<LineItemEntity> lineItemList;

    /** Creates a new instance of DisplayReceiptCreationResult */
    public ReceiptSheetManagedBean() {
    }
    public void initView(PhaseEvent event){
         if (receipt == null) {
            receipt = (ReceiptEntity) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("receipt");
        }
         invoice = receipt.getInvoice();
         company = invoice.getDeliveryOrder().getParentSalesOrder().getCustomer();
         lineItemList = invoice.getDeliveryOrder().getLineItems();
    }
    public void viewRecord() throws IOException{
          FacesContext.getCurrentInstance().getExternalContext().getFlash().put("receipt", receipt);
          FacesContext.getCurrentInstance().getExternalContext().redirect("displayReceipt.xhtml");
    }
    public void sendToEmail(){
        
    }

    public ReceiptEntity getReceipt() {
        return receipt;
    }

    public void setReceipt(ReceiptEntity receipt) {
        this.receipt = receipt;
    }

    public InvoiceEntity getInvoice() {
        return invoice;
    }

    public void setInvoice(InvoiceEntity invoice) {
        this.invoice = invoice;
    }

    public CompanyEntity getCompany() {
        return company;
    }

    public void setCompany(CompanyEntity company) {
        this.company = company;
    }

    public List<LineItemEntity> getLineItemList() {
        return lineItemList;
    }

    public void setLineItemList(List<LineItemEntity> lineItemList) {
        this.lineItemList = lineItemList;
    }
}
